﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReExamDAL : SyncBase<Model.ReExam>
    {
        static ReExamDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReExamDAL.addSQL = @"insert into TempReExam(
LessionID,TeacherID,ExamBatch,ExamTime,ExamPiont,SubjectNum,RecordTime,IsEnd)
 values (
@LessionID,@TeacherID,@ExamBatch,@ExamTime,@ExamPiont,@SubjectNum,@RecordTime,@IsEnd)";
            ReExamDAL.tbName = "TempReExam";
            ReExamDAL.remoteUrl = "/Ayyfford/AddReExam";
            ReExamDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2}, {3}, {4}, {5}, {6},{7}),",
                            t.LessionID.NullNumber(), t.TeacherID.NullNumber(), t.ExamBatch.NullNumber(), t.ExamTime.NullDate(), t.ExamPiont.NullNumber(), t.SubjectNum.NullNumber(), t.RecordTime.NullDate(), t.IsEnd ? 1 : 0);
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReExam t)
        {
            SyncBase<Model.ReExam>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReExam>.AsyncData();
        }
    }
}
